package com.srwl.mytx.domain;

import android.os.Parcel;
import android.os.Parcelable;

import com.srwl.mytx.domain.LatLng;
import com.srwl.mytx.domain.User;

import java.util.Date;

public class Coupon implements Parcelable{
    private String id;

    private String uId;

    private String tId;

    private String parentId;//一对多红包，父红包Id

    private Integer totalCount;//一对多红包 总数

    private Integer receivedCount;//一对多红包 接收数量

    private String outRequestNo;

    private Double amount;

    private Double balance;//一对多红包，剩余未领取的金额

    private String authNo;

    private String operationId;

    private LatLng location;

    private Integer status;

    private Integer type;

    private Date updated;

    private Date created;

    private String greeting;

    private User targetUser;

    private String liveRoomId;//依附的直播间id，用于红包被领完的时候去清除主题里面的红包

    private String topicId;//依附的主题id,用于红包被领完的时候去清除主题里面的红包

    private int chatType;

    private boolean isSendMessage;
    private Date expiryDate;

    public Coupon(String id, String uId, String tId, String parentId, Integer totalCount, Integer receivedCount, String outRequestNo, Double amount, Double balance, String authNo, String operationId, LatLng location, Integer status, Integer type, Date updated, Date created, String greeting, User targetUser, String liveRoomId, String topicId, int chatType, boolean isSendMessage, Date expiryDate) {
        this.id = id;
        this.uId = uId;
        this.tId = tId;
        this.parentId = parentId;
        this.totalCount = totalCount;
        this.receivedCount = receivedCount;
        this.outRequestNo = outRequestNo;
        this.amount = amount;
        this.balance = balance;
        this.authNo = authNo;
        this.operationId = operationId;
        this.location = location;
        this.status = status;
        this.type = type;
        this.updated = updated;
        this.created = created;
        this.greeting = greeting;
        this.targetUser = targetUser;
        this.liveRoomId = liveRoomId;
        this.topicId = topicId;
        this.chatType = chatType;
        this.isSendMessage = isSendMessage;
        this.expiryDate = expiryDate;
    }


    public Coupon() {
    }

    public Date getExpiryDate() {
        return expiryDate;
    }

    public void setExpiryDate(Date expiryDate) {
        this.expiryDate = expiryDate;
    }

    public Coupon(String id) {
        this.id = id;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getuId() {
        return uId;
    }

    public void setuId(String uId) {
        this.uId = uId == null ? null : uId.trim();
    }

    public String getOutRequestNo() {
        return outRequestNo;
    }

    public void setOutRequestNo(String outRequestNo) {
        this.outRequestNo = outRequestNo == null ? null : outRequestNo.trim();
    }

    public String getParentId() {
        return parentId;
    }

    public void setParentId(String parentId) {
        this.parentId = parentId;
    }

    public Integer getTotalCount() {

        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Integer getReceivedCount() {
        return receivedCount;
    }

    public void setReceivedCount(Integer receivedCount) {
        this.receivedCount = receivedCount;
    }

    public Double getBalance() {
        return balance;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public String getAuthNo() {
        return authNo;
    }

    public void setAuthNo(String authNo) {
        this.authNo = authNo == null ? null : authNo.trim();
    }

    public String getOperationId() {
        return operationId;
    }

    public void setOperationId(String operationId) {
        this.operationId = operationId == null ? null : operationId.trim();
    }

    public LatLng getLocation() {
        return location;
    }

    public void setLocation(LatLng location) {
        this.location = location;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public String gettId() {
        return tId;
    }

    public void settId(String tId) {
        this.tId = tId == null ? null : tId.trim();
    }

    public String getGreeting() {
        return greeting;
    }

    public void setGreeting(String greeting) {
        this.greeting = greeting;
    }

    public User getTargetUser() {
        return targetUser;
    }

    public void setTargetUser(User targetUser) {
        this.targetUser = targetUser;
    }

    public String getLiveRoomId() {
        return liveRoomId;
    }

    public void setLiveRoomId(String liveRoomId) {
        this.liveRoomId = liveRoomId;
    }

    public String getTopicId() {
        return topicId;
    }

    public void setTopicId(String topicId) {
        this.topicId = topicId;
    }

    public int getChatType() {
        return chatType;
    }

    public void setChatType(int chatType) {
        this.chatType = chatType;
    }

    public boolean isSendMessage() {
        return isSendMessage;
    }

    public void setSendMessage(boolean sendMessage) {
        isSendMessage = sendMessage;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.uId);
        dest.writeString(this.tId);
        dest.writeString(this.parentId);
        dest.writeValue(this.totalCount);
        dest.writeValue(this.receivedCount);
        dest.writeString(this.outRequestNo);
        dest.writeValue(this.amount);
        dest.writeValue(this.balance);
        dest.writeString(this.authNo);
        dest.writeString(this.operationId);
        dest.writeParcelable(this.location, flags);
        dest.writeValue(this.status);
        dest.writeValue(this.type);
        dest.writeLong(this.updated != null ? this.updated.getTime() : -1);
        dest.writeLong(this.created != null ? this.created.getTime() : -1);
        dest.writeString(this.greeting);
        dest.writeParcelable(this.targetUser, flags);
        dest.writeString(this.liveRoomId);
        dest.writeString(this.topicId);
        dest.writeInt(this.chatType);
        dest.writeByte(this.isSendMessage ? (byte) 1 : (byte) 0);
        dest.writeLong(this.expiryDate != null ? this.expiryDate.getTime() : -1);
    }

    protected Coupon(Parcel in) {
        this.id = in.readString();
        this.uId = in.readString();
        this.tId = in.readString();
        this.parentId = in.readString();
        this.totalCount = (Integer) in.readValue(Integer.class.getClassLoader());
        this.receivedCount = (Integer) in.readValue(Integer.class.getClassLoader());
        this.outRequestNo = in.readString();
        this.amount = (Double) in.readValue(Double.class.getClassLoader());
        this.balance = (Double) in.readValue(Double.class.getClassLoader());
        this.authNo = in.readString();
        this.operationId = in.readString();
        this.location = in.readParcelable(LatLng.class.getClassLoader());
        this.status = (Integer) in.readValue(Integer.class.getClassLoader());
        this.type = (Integer) in.readValue(Integer.class.getClassLoader());
        long tmpUpdated = in.readLong();
        this.updated = tmpUpdated == -1 ? null : new Date(tmpUpdated);
        long tmpCreated = in.readLong();
        this.created = tmpCreated == -1 ? null : new Date(tmpCreated);
        this.greeting = in.readString();
        this.targetUser = in.readParcelable(User.class.getClassLoader());
        this.liveRoomId = in.readString();
        this.topicId = in.readString();
        this.chatType = in.readInt();
        this.isSendMessage = in.readByte() != 0;
        long tmpExpiryData = in.readLong();
        this.expiryDate = tmpExpiryData == -1 ? null : new Date(tmpExpiryData);
    }

    public static final Creator<Coupon> CREATOR = new Creator<Coupon>() {
        @Override
        public Coupon createFromParcel(Parcel source) {
            return new Coupon(source);
        }

        @Override
        public Coupon[] newArray(int size) {
            return new Coupon[size];
        }
    };
}